Repository navigation
fix(lint): report a file the HTML parser refuses as a finding instead of failing the run - #8853
Conversation
… of failing the run
Edit accuracy: accurate 273 (base branch 271), smooth 57 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
|
Since the body was written, |
jrusso1020
left a comment
There was a problem hiding this comment.
Approve at dadad499. The new commit adds docs and one test on top of 47577048, which I reviewed below: the lint-rules.mdx entry for html_read_unlike_browser, and a URL-encoded mounted file that keeps the rest of the report (5/5 on 3 runs).
What I checked:
- One owner:
readableHtml.tscatches onlyHtmlReadUnlikeBrowserError, and any other parser error still throws.lintHyperframeHtmlreturns the singlehtml_read_unlike_browsererror (ok: false) before running rules, so a file the parser refuses cannot pass lint silently. - Project checks: every non-rule
parseHTMLcall inproject.tsandhevcPreviewLint.tsnow goes throughparseLintHtml.grepfinds no directparseHTML(left inpackages/lint/srcoutsiderules/and the helper. The rules only run on files that already parsed. - Mounted-file check:
lintMissingOrEmptySubCompositionnames the refusal for a mounted file, including one outsidecompositions/. - CLI:
lintProjectandcommands/lint.tsdon't parse HTML themselves, so the CLI goes through the same path.
Red-first, which I ran myself: with main's hyperframeLinter.ts, project.ts and hevcPreviewLint.ts, all 4 tests named on the "fails without the fix:" line fail. At head, htmlReadUnlikeBrowser.test.ts passes 4/4 on 3 runs, and the full lint suite passes 31 files and 1,363 tests.
Nit, not blocking: every file is now parsed once more for the refusal check before the rules parse it again. It's still linear, but if the linear-time check (#8837) gets tight, return the parsed document from the check and reuse it.
Need ✅ · Size ✅ (+140/−16, half tests) · Reuse ✅ (the parser's own error class and message) · Simpler ✅ · Structure ✅ (one owner for the refusal)
Risk: low. Files that parse lint exactly as before. A refused file becomes one error and no longer aborts the run.
— Rames
What
hyperframes lintnow reports a file that the HTML parser refuses as an error finding on that file. Before, the whole run failed withruntime_errorand no findings.Why
parseHTMLfrom@hyperframes/parsers/linkedomrefuses HTML that a browser would read as a different tree. One example is markup hidden in a comment inside an svg<title>. Preview and render refuse such a file, which is right. Lint parses every file through the same function, though, and never caught the refusal. So one refused file in a project ended the lint run before it reported anything, and the run named neither the file nor any other problem.How
packages/lint/src/readableHtml.tsis lint's one owner for a refused file:htmlReadUnlikeBrowserFindingturns the refusal into anhtml_read_unlike_browsererror finding that carries the parser's own message.parseLintHtmlreads a refused file as an empty document. Every other check therefore skips that file instead of throwing.lintHyperframeHtmlreturns that single finding for a refused file and runs no rules on it. That covers the root file, every file undercompositions/, and any caller that lints one file.project.tsandhevcPreviewLint.tsparse throughparseLintHtml. The project-wide checks (mounted sources, linked styles and scripts, audio, assets, video) no longer throw on a refused file.compositions/that no per-file pass lints. Its message readsdata-composition-src references "<file>", but the parser refuses it. <parser message>. This is the same check that already reports a mounted file that is empty or can't be parsed.The rules in
rules/still callparseHTMLdirectly. They only run on a file that has already parsed.No visible change
Lint results for files that parse are unchanged. A refused file now shows up as one error on that file, and the rest of the project is still linted.
Test plan
fails without the fix: the four cases in
packages/lint/src/htmlReadUnlikeBrowser.test.ts:is one error finding when linted on its own;is a finding on the root, not a failed run;is a finding on its own file while the rest of the project is still linted;is named when a scene outside compositions/ mounts it.On main each one throws
HtmlReadUnlikeBrowserError. With the fix they pass, three runs in a row.With the fix, the whole lint suite passes (31 files, 1,363 tests), and lint
tsc, oxlint, oxfmt and fallow are clean.Manual: I ran
hyperframes lint <dir> --jsonfrom the CLI source against a project whosecompositions/scene.htmlhides markup in an svg<title>comment.{"error":{"code":"runtime_error", ...}}with no findings.html_read_unlike_browseroncompositions/scene.html, next to the project's other findings.